package com.seo4j.adb4j.gui;

import com.seo4j.adb4j.device.listener.IAndroidDevice;

import javax.swing.table.AbstractTableModel;
import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;

import static com.seo4j.adb4j.gui.AdbGUI.DEVICE_MAP;

public class DeviceTableModel extends AbstractTableModel {
    private static final ResourceBundle BUNDLE = ResourceBundle.getBundle("com.seo4j.adb4j.gui.messages"); //$NON-NLS-1$


    private final String[] headers = {BUNDLE.getString("Flag"), "IMEI", BUNDLE.getString("Serial-SIM"), BUNDLE.getString("Location"), BUNDLE.getString("Phone-Number"), BUNDLE.getString("Operator"), BUNDLE.getString("Country-SIM"), BUNDLE.getString("Operator-SIM"),};


    public DeviceTableModel() {
        super();
    }

    @Override
    public int getRowCount() {
        return DEVICE_MAP.size();
    }

    @Override
    public int getColumnCount() {
        return headers.length;
    }

    @Override
    public String getColumnName(int columnIndex) {
        return headers[columnIndex];
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        List<IAndroidDevice> list = new ArrayList<IAndroidDevice>();
        list.addAll(AdbGUI.DEVICE_MAP.values());
        switch (columnIndex) {
            case 0:
                return list.get(rowIndex).getName();
            case 1:
                return list.get(rowIndex).getDeviceId();
            case 2:
                return list.get(rowIndex).getSerialNo();

            default:
                return null;
        }
    }

}
